More fixes.
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 22:06:01 +0000 (22:06 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 22:06:01 +0000 (22:06 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4685 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/g7towin.cc
gpsbabel/gopal.cc
gpsbabel/gtm.cc
gpsbabel/hiketech.cc
gpsbabel/holux.cc
gpsbabel/ik3d.cc

index fa25e7f90871020d3b7cf5348715701bfec56fb9..67c22ab2712174bbc986dcb66c20541912a6a579 100644 (file)
@@ -109,7 +109,7 @@ parse_line(char* buff, int index, const char* delimiter, waypoint* wpt)
       break;
 
     case WAYPT__OFS + 1:
-      wpt->description = xstrdup(cin);
+      wpt->description = (cin);
       break;
 
     case WAYPT__OFS + 2:
@@ -129,14 +129,7 @@ parse_line(char* buff, int index, const char* delimiter, waypoint* wpt)
 
     case WPT_cA_OFS + 1:
     case WPT_c1_OFS + 1:
-#if NEW_STRINGS
       wpt->shortname = cin;
-#else
-      if (wpt->shortname) {
-        xfree(wpt->shortname);
-      }
-      wpt->shortname = xstrdup(cin);
-#endif
       break;
 
     case WPT_cA_OFS + 4:
@@ -298,7 +291,9 @@ parse_waypt(char* buff)
     cin--;
   }
   if (cin >= buff) {
-    wpt->shortname = xstrndup(buff, cin - buff + 1);
+    char*s = xstrndup(buff, cin - buff + 1);
+    wpt->shortname = s;
+    xfree(s);
   }
 
   if (gardown) {
@@ -549,7 +544,7 @@ data_read(void)
             s = strrchr(cdata, ',');
             if (s) {
               *s = '\0';
-              head->rte_name = xstrdup(cdata);
+              head->rte_name = cdata;
             }
           }
         }
@@ -562,7 +557,7 @@ data_read(void)
       head = route_head_alloc();
       cdata += 3; /*skip route number */
       if (*cdata) {
-        head->rte_name = xstrdup(cdata);
+        head->rte_name = cdata;
       }
       route_add_head(head);
       break;
index d13a0570e25822093b9a358aeb9c409ed4813814..72106488cb5e32fbb2604b024836c471829eefa0 100644 (file)
@@ -184,7 +184,7 @@ gopal_read(void)
   strftime(routename,sizeof(routename),"Tracklog %c",gmtime(&tx));
 
   route = route_head_alloc();
-  route->rte_name=xstrdup(routename);
+  route->rte_name = routename;
   route_add_head(route);
 
   line=0;
index 449f8a097595e82b0eea4cab883a0078b8307d45..f98ddd1fcf65b3c8480524b41d3e446a0f734650 100644 (file)
@@ -72,7 +72,7 @@ fread_bool(gbfile* fd)
 #define fread_single(a) gbfgetflt(a)
 #define fread_double(a) gbfgetdbl(a)
 
-static char*
+QString
 fread_string(gbfile* fd)
 {
   char* val;
@@ -88,20 +88,18 @@ fread_string(gbfile* fd)
     len--;
   }
   val[len] = 0;
-  return val;
+  QString v(val);
+  xfree(val);
+  return v;
 }
 
 static void
 fread_string_discard(gbfile* fd)
 {
-  char* temp = fread_string(fd);
-
-  if (temp != NULL) {
-    xfree(temp);
-  }
+  fread_string(fd);
 }
 
-static char*
+QString
 fread_fixedstring(gbfile* fd, int len)
 {
   char* val = (char*) xmalloc(len+1);
@@ -111,7 +109,10 @@ fread_fixedstring(gbfile* fd, int len)
     len--;
   }
   val[len] = 0;
-  return val;
+  QString v(val);
+  xfree(val);
+
+  return v;
 }
 
 /* Write functions, according to specification. */
@@ -394,20 +395,18 @@ static void
 gtm_rd_init(const char* fname)
 {
   int version;
-  char* name;
   file_in = gbfopen_le(fname, "rb", MYNAME);
   version = fread_integer(file_in);
-  name = fread_fixedstring(file_in, 10);
+  QString name = fread_fixedstring(file_in, 10);
   if (version == -29921) {
     fatal(MYNAME ": Uncompress the file first\n");
   }
-  if (strcmp(name, "TrackMaker") != 0) {
+  if (name != "TrackMaker") {
     fatal(MYNAME ": Invalid file format\n");
   }
   if (version != 211) {
     fatal(MYNAME ": Invalid format version\n");
   }
-  xfree(name);
 
   /* Header */
   fread_discard(file_in, 15);
@@ -515,7 +514,6 @@ gtm_read(void)
   route_head* rte_head = NULL;
   waypoint* wpt;
   int real_tr_count = 0;
-  char* route_name;
   unsigned int icon;
   int i;
 
@@ -603,7 +601,7 @@ gtm_read(void)
     convert_datum(&wpt->latitude, &wpt->longitude);
     wpt->shortname = fread_fixedstring(file_in, 10);
     wpt->description = fread_string(file_in);
-    route_name = fread_string(file_in);
+    QString route_name = fread_string(file_in);
     icon = fread_integer(file_in);
     if (icon < sizeof(icon_descr)/sizeof(char*)) {
       wpt->icon_descr = icon_descr[icon];
@@ -621,8 +619,6 @@ gtm_read(void)
       rte_head = route_head_alloc();
       rte_head->rte_name = route_name;
       route_add_head(rte_head);
-    } else {
-      xfree(route_name);
     }
     route_add_wpt(rte_head, wpt);
   }
index 1b14f65d0763e764610f44a57245ac29f9dad858..99bb7bb574deaf7566c4c306f5e3be84502d82b5 100644 (file)
@@ -200,7 +200,7 @@ void         ht_wpt_s(xg_string args, const QXmlStreamAttributes* unused)
 static
 void   ht_ident(xg_string args, const QXmlStreamAttributes* unused)
 {
-  wpt_tmp->shortname = xstrdup(args);
+  wpt_tmp->shortname = args;
 }
 
 static
@@ -212,31 +212,19 @@ void      ht_sym(xg_string args, const QXmlStreamAttributes* unused)
 static
 void   ht_lat(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->latitude = args.toDouble();
-#else
-  wpt_tmp->latitude = atof(args);
-#endif
 }
 
 static
 void   ht_long(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->longitude = args.toDouble();
-#else
-  wpt_tmp->longitude = atof(args);
-#endif
 }
 
 static
 void   ht_alt(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->altitude = args.toDouble();
-#else
-  wpt_tmp->altitude = atof(args);
-#endif
 }
 
 static
@@ -262,7 +250,7 @@ void        ht_trk_e(xg_string args, const QXmlStreamAttributes* unused)
 static
 void   ht_trk_ident(xg_string args, const QXmlStreamAttributes* unused)
 {
-  trk_head->rte_name = xstrdup(args);
+  trk_head->rte_name = args;
 }
 
 static
@@ -299,31 +287,19 @@ void      ht_trk_utc(xg_string args, const QXmlStreamAttributes* unused)
 static
 void   ht_trk_lat(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->latitude = args.toDouble();
-#else
-  wpt_tmp->latitude = atof(args);
-#endif
 }
 
 static
 void   ht_trk_long(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->longitude = args.toDouble();
-#else
-  wpt_tmp->longitude = atof(args);
-#endif
 }
 
 static
 void   ht_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->altitude = args.toDouble();
-#else
-  wpt_tmp->altitude = atof(args);
-#endif
 }
 
 
index 81410670625df4f24508177c18ffd2010ea655f2..2ba4a58627b4534d7270bf8234a97868d21b0d70 100644 (file)
@@ -117,8 +117,8 @@ static void data_read(void)
     strncpy(desc,pWptHxTmp->comment,sizeof(pWptHxTmp->comment));
     desc[sizeof(pWptHxTmp->comment)]=0;
 
-    wpt_tmp->shortname = xstrdup(name);
-    wpt_tmp->description = xstrdup(desc);
+    wpt_tmp->shortname = name;
+    wpt_tmp->description = desc;
 
     wpt_tmp->SetCreationTime(0);
     if (pWptHxTmp->date.year) {
index 32f1cf81ededece8ad0836311d38a393277e4419..65a5d67e801db7b0ab3cd14e3c937b028d5592f9 100644 (file)
@@ -31,7 +31,7 @@ static arglist_t ikt_args[] = {
 
 #define MYNAME "ikt"
 
-static char* name, *text;
+static QString name, text;
 
 static route_head* track;
 static waypoint* waypt;
@@ -59,22 +59,14 @@ ikt_object_end(void)
   if (track) {
     track->rte_name = name;
     track_add_head(track);
-    name = NULL;
   } else if (waypt) {
     waypt->shortname = name;
     waypt->description = text;
     waypt_add(waypt);
-    name = NULL;
-    text = NULL;
-  }
-  if (name) {
-    xfree(name);
-    name = NULL;
-  }
-  if (text) {
-    xfree(text);
-    text = NULL;
   }
+
+  name = QString();
+  text = QString();
   track = NULL;
   waypt = NULL;
 }
@@ -102,13 +94,13 @@ iktobj_trkpt(xg_string args, const QXmlStreamAttributes* attrv)
 static void
 iktobj_name(xg_string args, const QXmlStreamAttributes* unused)
 {
-  name = xstrdup(args);
+  name = args;
 }
 
 static void
 iktobj_text(xg_string args, const QXmlStreamAttributes* unused)
 {
-  text = xstrdup(args);
+  text = args;
 }
 
 static void
@@ -138,8 +130,8 @@ ikt_rd_init(const char* fname)
 
   track = NULL;
   waypt = NULL;
-  name = NULL;
-  text = NULL;
+  name = QString();
+  text = QString();
 }
 
 static void
@@ -152,13 +144,6 @@ static void
 ikt_rd_deinit(void)
 {
   ikt_object_end();
-  if (name) {
-    xfree(name);
-  }
-  if (text) {
-    xfree(text);
-  }
-
   xml_deinit();
 }